Expressions (func. params)

Prev Next

Introduction

A expression is a a value, a fuction call or a calculation which returns a value. The individual functions may impose additional requirements, for exmplae that the expression must return boolean values true or false.

The while() loop function is a good example where the expression inside is calculated several times while the function is executed. In addition, various functions containing ... selected rows ... in their names make use expressions as code pieces.

Attention: Parentheses are required when the expression coontains a comparison operator using = or <>. The reason is that these two comparison operators may expect more than one value separated with commas and they would, if parenthese are not used, hijack the remaining function parameters as additional values to compare. No extra parentheses are required when the expression is in the last function parameter or is the only one function parameter.
No extra parentheses are required if the expression begins with following operators: <, <=, >, <=, ==, and !=.
No extra parentheses are required if the expression is provided in a string value.

  table initialize( primes,
    { Number, 2, 3, 5, 7, 10, 11, 13, 17, 23, 31, 37, A, a, Hello } );

  table process selected rows( primes, ([Number]=11,37),   echo( [Number],": ", "is 11 or 37" ) );
  table process selected rows( primes,  [Number]==13,      echo( [Number],": ", "thirteen" ) );
  table process selected rows( primes, ([Number]='H*'),    echo( [Number],": ", "Begins with H" ) );
  table process selected rows( primes, ([Number]=3..5,10), echo( [Number],": ", "is one of 3..5,10" ) );

  echo; // Do the same with expression in strings.  No parentheses needed-

  c[] = '[Number] = 3..5,10'; //
  table process selected rows( primes, :c[], echo( [Number],": ", "is one of 3..5,10" ) );

  c[] = "[Number] = 'H*'";
  table process selected rows( primes, :c[], echo( [Number],": ", "Begins with H" ) );
11: is 11 or 37
37: is 11 or 37
13: thirteen
Hello: Begins with H
3: is one of 3..5,10
5: is one of 3..5,10
10: is one of 3..5,10

3: is one of 3..5,10
5: is one of 3..5,10
10: is one of 3..5,10
Hello: Begins with H
Try it yourself: Open LAN_Features_Expressions_[func_params].b4p in B4P_Examples.zip. Decompress before use.